// Learn cc.Class:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
import LanguageMng from "../Managers/LanguageMng";
cc.Class({
    extends: cc.Component,

    properties: {
        labelDay:{
            default:null,
            type:cc.Label
        },

        labelCoin:{
            default:null,
            type:cc.Label
        },

        collectButtonNode:{
            default:null,
            type:cc.Node
        }

    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {

    },

    // update (dt) {},

    initDailyCoin:function (data,cb) {
        if(!data){
            this.node.active = false
            return
        }
        this.labelDay.string = LanguageMng.getSentence(173) + data.day
        this.labelCoin.string = cc.gg.gameDataUtil.getStringOfRupee(data.coin)
        this.cb = cb
    },

    onCelectionButtonClicked:function (event) {
        if(this.cb) this.cb()
        return



        cc.gg.toastMgr.showNetWaitting(function () {
            cc.gg.httpUtil.httpPost("/activities/collect",{activityId:1001},function (result) {
                cc.gg.toastMgr.removeNetWaitting()

                if (!result.succ) {
                    cc.error(result.msg)
                    return
                }

                cc.find("Canvas").emit("refresh_activity")

            }.bind(this))
        }.bind(this))
    }
});
